package cn.evun.tms.generator.task;

import cn.evun.tms.generator.framework.AbstractApplicationTask;
import cn.evun.tms.generator.framework.context.ApplicationContext;
import cn.evun.tms.generator.handler.BaseHandler;
import cn.evun.tms.generator.handler.impl.InfoPageHandler;
import cn.evun.tms.generator.model.InfoPageInfo;

import java.util.List;

public class InfoPageTask extends AbstractApplicationTask {

	private static String INFOPAGE_FTL = "template/InfoPage.ftl";

	@SuppressWarnings("unchecked")
	@Override
	protected boolean doInternal(ApplicationContext context) throws Exception {
		logger.info("开始生成infopage。。。");

		List<InfoPageInfo> infoPageInfos = (List<InfoPageInfo>) context.getAttribute("infoPageInfos");

		BaseHandler<InfoPageInfo> baseHandler = null;
		for (InfoPageInfo infoPageInfo : infoPageInfos) {
			baseHandler = new InfoPageHandler(INFOPAGE_FTL, infoPageInfo);
			baseHandler.execute(context);
		}

		logger.info("结束生成infopage。。。");
		return false;
	}


}
